<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * Transfer模型
 */
class BlockchainTransfer extends ModelBase
{

    protected $insert = ['create_time','serial_number'];

    /**
     * 流水号自动完成
     */
    public function setSerialNumberAttr($value)
    {

        return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
    }

    /**
     * 连用户表
     */
    public function member(){
        return $this->belongsTo('Member','user_id','id');
    }


    /**
     * 连钱包表
     */
    public function wallet(){
        return $this->belongsTo('Wallet','wallet_id','id');
    }


    /**
     * logo
     */
    public function getNumberAttr($value)
    {
        return  sprintf("%.2f",$value);

    }
    /**
     * 获取状态信息
     */
    public function getStateTextAttr(){
        $arr=['待审核','成功','失败','待到账'];
        return $arr[$this->state];
    }

    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr()
    {

        return TIME_NOW;
    }
}
